package com.luckmgr.service.impl;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.common.service.BaseService;
import com.luckmgr.dao.ActivityLevelMapper;
import com.luckmgr.dao.LevelPrizeMapper;
import com.luckmgr.dao.LuckUserMapper;
import com.luckmgr.entity.db.ActivityLevel;
import com.luckmgr.service.ActivityLevelService;


@Service
public class ActivityLevelServiceImpl extends BaseService<ActivityLevel> implements ActivityLevelService {

	
	@Autowired
	LevelPrizeMapper levelPrizeMapper;
	
	ActivityLevelMapper activityLevelMapper;
	
	@Autowired
	LuckUserMapper luckUserMapper;
	
	@Resource(name="activityLevelMapper")
    public void initCompanyMapper(ActivityLevelMapper activityLevelMapper) {
		this.activityLevelMapper = activityLevelMapper;
        super.setBaseDao(activityLevelMapper);
    }

	@Override
	public List<ActivityLevel> findLevelByAid(Integer id) {
		// TODO Auto-generated method stub
		return activityLevelMapper.findLevelByAid(id);
	}

	@Override
	public void deleteLevel(Integer id) {
		luckUserMapper.deleteByLevel(id);
		levelPrizeMapper.deleteLevel(id);
		activityLevelMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int updateBlackUser(Integer aid, String users) {
		if(users.length()>0){
			String[] arrayUsers = users.split(",");
			luckUserMapper.updateBlackUser(aid,arrayUsers);
		}
		return 1;
	}

	
	
}